<template>
    <div>
        <van-button
            size="small"
            type="primary"
            class="btn_vant_btn"
            @click="backHome">返回首页
        </van-button>
        <van-button
            size="small"
            type="danger"
            class="btn_vant_btn">
            	返回上一页({{ second }}s)
        </van-button>
    </div>
</template>

<script>
import './error.less'
import {
    Button
} from 'vant';
export default {
    name: 'BackBtnGroup',
    components: {
        [Button.name]:Button
    },
    data () {
        return {
            second: 5,
            timer: null
        }
    },
    methods: {
        backHome () {
            this.$router.replace({
                name: 'index'
            })
        },
        backPrev () {
            this.$router.go(-1)
        }
    },
    mounted () {
        this.timer = setInterval(() => {
            if (this.second === 0) this.backPrev()
            else this.second--
        }, 1000)
    },
    beforeDestroy () {
        clearInterval(this.timer)
    }
}
</script>
